<%@page import="com.railway.msg.model.*"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<html>

	<head>
	
			<link rel="stylesheet" type="text/css" href="${ctx}/css/default.css" />
		<link rel="stylesheet" href="${ctx}/css/ztree.css" type="text/css">
		<link rel="stylesheet" href="${ctx}/css/zTreeStyle/zTreeStyle.css"
			type="text/css">
		
		
		<link href="${ctx}/commons/upload/css/uploadify.css" rel="stylesheet"
			type="text/css" />
		<script type="text/javascript"
			src="${ctx}/scripts/jquery-1.4.2.min.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/jquery.easyui.min.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/locale/easyui-lang-zh_CN.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/jquery-1.4.4.min.js"></script>
		<script type="text/javascript"
			src="${ctx}/commons/upload/js/swfobject.js"></script>
		<script type="text/javascript"
			src="${ctx}/commons/upload/js/jquery.uploadify.v2.1.4.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/jquery.ztree.core-3.0.min.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/jquery.ztree.excheck-3.0.min.js"></script>

		<script type="text/javascript"> 
	
	var setting = {
			check: {
				enable: true,
				chkboxType: { "Y" : "ps", "N" : "ps" }
			},
			view: {
				dblClickExpand: false
			},
			data: {
				simpleData: {
					enable: true
				}
			},
			callback: {
				beforeClick: beforeClick,
				onCheck: onCheck
			}
		};


     
		function beforeClick(treeId, treeNode) {
			var zTree = $.fn.zTree.getZTreeObj("treeDemo");
			zTree.checkNode(treeNode, !treeNode.checked, null, true);
			return false;
		}
		
		function onCheck(e, treeId, treeNode) {

			var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
			nodes = zTree.getCheckedNodes(true),
			v = "";
	
			for (var i=0, l=nodes.length; i<l; i++) {
				if(nodes[i].type == 1){
				var tt = nodes[i].id;
		     	form1.targetids.value +=   tt.substring(1,tt.length) + ",";
				v += nodes[i].name + ",";}
			}
			if (v.length > 0 ) v = v.substring(0, v.length-1);
			var cityObj = $("#citySel");
			cityObj.attr("value", v);
		}

		function showMenu() {
			var cityObj = $("#citySel");
			
			var cityOffset = $("#citySel").offset();
			
			$("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");

			$("body").bind("mousedown", onBodyDown);
		}
		function hideMenu() {
			$("#menuContent").fadeOut("fast");
			$("body").unbind("mousedown", onBodyDown);
		}
		function onBodyDown(event) {
			if (!(event.target.id == "menuBtn" || event.target.id == "citySel" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
				hideMenu();
			}
		}
	        $(document).ready(function() {        	        
	            $.get("${ctx}/system/SysUser/getUserDept.do", {
	            
                Action:"get",Name:"user01"}, function (data, textStatus){		

             var zNodes = eval(data);
			//var zNodes =[
			//{"id":"1", "pId":"0", "name":"部门01", "open":"true", nocheck:false;,"type":"0"},
			//{"id":"11", "pId":"1", "name":"人员01","type":"1"},
			//{"id":"12", "pId":"1", "name":"人员02","type":"1"},
			//{"id":"13", "pId":"1", "name":"人员03","type":"1"}];
              
                $.fn.zTree.init($("#treeDemo"), setting, zNodes);
                
				});	
	        	
	            $("#fileupload").uploadify({
	           
	                 'allBytesLoaded':300 * 1024*1024,
	                /*注意前面需要书写path的代码*/ 
	                'uploader'       : '${ctx}/commons/upload/js/uploadify.swf', 
	                'script'         : '${ctx}/files/Files/upload.do', 
	                'cancelImg'      : '${ctx}/commons/upload/images/cancel.png', 
	                'queueID'        : 'fileQueue', //和存放队列的DIV的id一致 
	                'fileDataName'   : 'fileupload', //和以下input的name属性一致 
	                'auto'           : false, //是否自动开始 
	                'multi'          : false, //是否支持多文件上传 
	                'buttonText'     : '选择文件', //按钮上的文字 
	                'simUploadLimit' : 1, //一次同步上传的文件数目 
	                'sizeLimit'      : 30* 1024 * 1024, //设置单个文件大小限制 
	                'queueSizeLimit' : 1, //队列中同时存在的文件个数限制 
	                'fileDesc'       : '支持格式:jpg/gif/jpeg/png/bmp.', //如果配置了以下的'fileExt'属性，那么这个属性是必须的 
	                'fileExt'        : '*.zip;*.flv;*.jpg;*.gif;*.jpeg;*.png;*.bmp',//允许的格式   
	            onComplete: function (event, queueID, fileObj, response, data) { 
      			     var objs = eval("["+response+"]");	               
	                 form1.uploadedfileid.value = objs[0].uploadedfileid;            
	              
					$('<li></li>').appendTo('.files').text(objs[0].uploadedresult); 
	}, 
	onError: function(event, queueID, fileObj) { 
	             alert("文件:" + fileObj.name + "上传失败"); 
	       }, 
	       onCancel: function(event, queueID, fileObj){ 
	       alert("取消了" + fileObj.name); 
	       } 
	            }); 
	
	        }); 
	        </script>

		<script type="text/javascript"> 
	      
	function uploadifyUpload(){ 
	     if(form1.uploadedfileid.value  != null &&  form1.uploadedfileid.value != ""){
	                   alert("附件已添加!");
	                   return;
	                }
	   $('#fileupload').uploadifyUpload(); 
	} 
	</script>


		<title><%=MsgSend.TABLE_ALIAS%>新增</title>
	</head>
	<body>

		<div class="content_wrap">
	
		<div id="menuContent" class="menuContent"
			style=" position: absolute;">
			<ul id="treeDemo" class="ztree"
				style="margin-top: 0; width: 220px; height: 470px;"></ul>
		</div>
			<div class="right" >
				<form id="form1" action="${ctx}/msg/MsgSend/save.do" method="post">
					<input type="submit" value="提交" />
					<input type="button" value="返回列表"
						onclick="window.location='${ctx}/msg/MsgSend/list.do'" />
					<input type="button" value="后退" onclick="history.back();" />

					<table class="formTable">
						<input type="hidden" id="id" name="id" value="${model.id}" />
						<input type="hidden" name="uploadedfileid"
							value="${model.uploadedfileid}" />
						<input type="hidden" id="targetids" name="targetids"
							value="${model.targetids}" />

						<!-- tr>
							<td class="tdLabel">
								<%=MsgSend.ALIAS_TITLES%>:
							</td>
							<td>
								<input id="titles" name="titles" value="${model.titles}"
									type="text" class="easyui-validatebox" />
							</td>
						</tr-->


						<tr>
							<td class="tdLabel">
								<%=MsgSend.ALIAS_CONTENT%>:
							</td>



							<td>
								<textarea id="content" name="content" value="${model.content}"
									class="easyui-validatebox" rows="22" cols="200"
									style="width: 80%">
				</textarea>
							</td>
						</tr>

						<!--tr>	
				<td class="tdLabel">
					<%=MsgSend.ALIAS_ACCESSORY%>:
				</td>	
				<td>
					<input type="file" size="30" name="test" />
				</td>
			</tr>

			
			<tr>	
				<td class="tdLabel">
					<%=MsgSend.ALIAS_CREATOR%>:
				</td>	
				<td>
				<input id="creator" name="creator" value="${model.creator}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			<tr>	
				<td class="tdLabel">
					<%=MsgSend.ALIAS_CREATE_TIME%>:
				</td>	
				<td>
				<input value="${model.createTimeString}" id="createTimeString" name="createTimeString"  
				type="text" class="easyui-datebox"/>
				</td>
			</tr-->
			</table>
				</form>
				<table>
					<tr >
						<td>
							上传附件：
						</td>
						<td>
							<input type="file" name="fileupload" id="fileupload" />
							<div style="margin-top: 0; width: 200px; height: 10px;" id="fileQueue"></div>
							<p>
								<a href="javascript:;" onClick="javascript:uploadifyUpload()">开始上传</a>&nbsp;
								<a href="javascript:jQuery('#fileupload').uploadifyClearQueue()">取消所有上传</a>
							</p>
							<ol class=files></ol>
						</td>
				</table>
			</div>
		</div>

	
	</body>

</html>

